/**
 * 作者：陈文斌 on 2018/12/27.
 * 邮箱：chen_wennbin@163.com
 * 版本：v1.0
 */

import 'package:flutter/material.dart';
import 'package:crm/constant/constant.dart';
import 'package:crm/page/SettingPassword/crm_setting_text_password_page.dart';
import 'package:crm/view/AppBar/custom_app_bar.dart';

const String Title = '设置密码';

class FirstLoginPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _FirstLoginPageState();
}

class _FirstLoginPageState extends State<FirstLoginPage> {
  Widget _avatarSection() {
    return Container(
      width: AppScreen.setWidth(110),
      height: AppScreen.setWidth(110),
      margin: EdgeInsets.fromLTRB(
        AppScreen.setWidth(131),
        AppScreen.setHeight(34),
        AppScreen.setWidth(131),
        AppScreen.setHeight(34),
      ),
      child: Image.asset(
        AppImagePaths.AvatarImage,
        fit: BoxFit.fill,
      ),
    );
  }

  Widget _textSection() {
    return Container(
      width: AppScreen.setWidth(180),
      margin: EdgeInsets.fromLTRB(
        AppScreen.setWidth(96),
        0,
        AppScreen.setWidth(96),
        AppScreen.setHeight(38),
      ),
      child: Text(
        '首次登录客户关系管理系统请设置密码',
        style: TextStyle(
          color: AppColors.DetailTextColor,
          fontSize: AppFontSizes.Font15,
          fontFamily: AppFontFamilies.PingFangSC,
          fontWeight: FontWeight.w500,
        ),
        textAlign: TextAlign.center,
      ),
    );
  }

  Widget _buttonSection() {
    return Container(
      width: AppScreen.setWidth(300),
      height: 42,
      margin: EdgeInsets.only(
        left: AppScreen.setWidth(36),
        right: AppScreen.setWidth(36),
      ),
      decoration: BoxDecoration(
        color: Color(0xFF3C86F3),
        borderRadius: BorderRadius.circular(21), // 圆角
      ),
      child: ClipRRect(
        borderRadius: BorderRadius.circular(21),
        child: MaterialButton(
          onPressed: () {
            Navigator.push(
              context,
              MaterialPageRoute(
                builder: (context) => SettingTextPasswordPage(),
              ),
            );
          },
          child: Text(
            '前往设置',
            style: TextStyle(
              fontSize: AppFontSizes.Font15,
              fontFamily: AppFontFamilies.PingFangSC,
              fontWeight: FontWeight.w500,
            ),
          ),
          textColor: Colors.white,
        ),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      backgroundColor: Colors.white,
      appBar: CustomAppBar(
        title: Title,
      ),
      body: Column(
        children: <Widget>[
          _avatarSection(),
          _textSection(),
          _buttonSection(),
        ],
      ),
    );
  }
}
